package com.darrenchan.leetcode;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-02-26 19:19
 */
public class Q965 {
    Set<Integer> set = new HashSet<>();

    public boolean isUnivalTree(TreeNode root) {
        if(root == null) {
            return true;
        }

        set.add(root.val);
        if(set.size() > 1) {
            return false;
        }

        return isUnivalTree(root.left) && isUnivalTree(root.right);

    }
}
